/*
 * @lc app=leetcode.cn id=1534 lang=typescript
 *
 * [1534] 统计好三元组
 */

// @lc code=start
function countGoodTriplets(
    arr: number[],
    a: number,
    b: number,
    c: number
): number {
    let count = 0;
    for (let i = 0; i < arr.length; i++) {
        for (let j = i + 1; j < arr.length; j++) {
            if (Math.abs(arr[i] - arr[j]) <= a) {
                for (let k = j + 1; k < arr.length; k++) {
                    if (
                        Math.abs(arr[k] - arr[j]) <= b &&
                        Math.abs(arr[i] - arr[k]) <= c
                    )
                        count++;
                }
            }
        }
    }
    return count;
}
// @lc code=end
